<html>
<head><meta charset="utf-8"><title>calling non-const-fn · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html">calling non-const-fn</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="147823456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147823456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147823456">(Nov 16 2018 at 15:29)</a>:</h4>
<p>Oh god what have we done... <code>find_mir</code> in CTFE fails to actually check if the function is const, and if I fix that I get two test failures...</p>



<a name="147823467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147823467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147823467">(Nov 16 2018 at 15:29)</a>:</h4>
<div class="codehilite"><pre><span></span>failures:
    [ui] ui/consts/const-call.rs
    [ui] ui/consts/const-eval/strlen.rs
</pre></div>


<p>still investigating the details</p>



<a name="147824198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147824198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147824198">(Nov 16 2018 at 15:38)</a>:</h4>
<p>I remember doing that change</p>



<a name="147824251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147824251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147824251">(Nov 16 2018 at 15:39)</a>:</h4>
<p>the test failures are just changing diagnostics I think</p>



<a name="147825007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147825007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147825007">(Nov 16 2018 at 15:50)</a>:</h4>
<blockquote>
<p>I remember doing that change</p>
</blockquote>
<p>doing what? I remember introducing <code>hook_fn</code></p>



<a name="147825076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147825076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147825076">(Nov 16 2018 at 15:51)</a>:</h4>
<p>ah but then you removed the <code>NonConst</code> error? oO</p>



<a name="147825159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147825159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147825159">(Nov 16 2018 at 15:52)</a>:</h4>
<p>I thought I had stated on multiple occasions that we should really error in this case, because otherwise we expose all sorts of stuff in the miri engine that we don't want exposed^^</p>



<a name="147825295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147825295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147825295">(Nov 16 2018 at 15:54)</a>:</h4>
<p>we fixed those ;)</p>



<a name="147825304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147825304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147825304">(Nov 16 2018 at 15:54)</a>:</h4>
<p>that was mainly miri running on mir that has typeck errors</p>



<a name="147825439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147825439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147825439">(Nov 16 2018 at 15:56)</a>:</h4>
<p>the miri engine still can do way more than was have stabilized</p>



<a name="147825475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147825475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147825475">(Nov 16 2018 at 15:57)</a>:</h4>
<p>and without this check, the moment we allow calling <code>const fn()</code> pointers, the entire engine becomes stabilized without any const qualification protecting us</p>



<a name="147825477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147825477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147825477">(Nov 16 2018 at 15:57)</a>:</h4>
<p>I do not think we want that</p>



<a name="147825955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147825955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147825955">(Nov 16 2018 at 16:03)</a>:</h4>
<p>hm, it considers <code>len()</code> non-const even though there is <code>#![feature(const_str_len, const_str_as_bytes)]</code>. any idea what might be causing this <span class="user-mention" data-user-id="124288">@Oli</span> ?</p>



<a name="147825986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147825986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147825986">(Nov 16 2018 at 16:03)</a>:</h4>
<p>Yea, that's why I removed it, our const check is broken</p>



<a name="147826053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147826053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147826053">(Nov 16 2018 at 16:04)</a>:</h4>
<p>cross crate evaluation with stability is really weird</p>



<a name="147826073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147826073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147826073">(Nov 16 2018 at 16:04)</a>:</h4>
<p>I mean, we already proved that something is const fn in the other crate</p>



<a name="147826095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147826095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147826095">(Nov 16 2018 at 16:04)</a>:</h4>
<p>we could do <code>is_const_fn_raw</code></p>



<a name="147826128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147826128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147826128">(Nov 16 2018 at 16:05)</a>:</h4>
<p>but then again, with function pointers you could escape the whole stability thing</p>



<a name="147826272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147826272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147826272">(Nov 16 2018 at 16:06)</a>:</h4>
<blockquote>
<p>I mean, we already proved that something is const fn in the other crate</p>
</blockquote>
<p>no we didn't. someone could have transmuted a function ptr.</p>



<a name="147826290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147826290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147826290">(Nov 16 2018 at 16:07)</a>:</h4>
<p>we just have to do the same check as const qualification, don't we?</p>



<a name="147826299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147826299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147826299">(Nov 16 2018 at 16:07)</a>:</h4>
<p>that somehow takes into account whether we have the necessary features enabled</p>



<a name="147826316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147826316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147826316">(Nov 16 2018 at 16:07)</a>:</h4>
<p>I'd have thought that's what <code>is_const_fn</code> is for?</p>



<a name="147826383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147826383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147826383">(Nov 16 2018 at 16:08)</a>:</h4>
<blockquote>
<p>I mean, we already proved that something is const fn in the other crate</p>
</blockquote>
<p>uh wait... this is not checking the <em>body</em>, is it? We want to check the <em>signature</em>, potentially with <code>rustc_const_unstable</code></p>



<a name="147826394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147826394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147826394">(Nov 16 2018 at 16:08)</a>:</h4>
<p>that is not something the other crate can have checked, so I do not understand your statement</p>



<a name="147826406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147826406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147826406">(Nov 16 2018 at 16:09)</a>:</h4>
<p>we assume that <em>if</em> the function is marked const in the other crate, the body got checked; that is fair. now we have to check if it is indeed marked as such.</p>



<a name="147827830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147827830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147827830">(Nov 16 2018 at 16:27)</a>:</h4>
<p>If we don't care about stability, <code>is_const_fn_raw</code> is what you want. It just checks for the keyword</p>



<a name="147827890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147827890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147827890">(Nov 16 2018 at 16:28)</a>:</h4>
<p><code>is_const _fn</code> also checks for stability things, but can't do so cross crate</p>



<a name="147827931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147827931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147827931">(Nov 16 2018 at 16:29)</a>:</h4>
<p>Const qualification is a static check</p>



<a name="147827945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147827945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147827945">(Nov 16 2018 at 16:29)</a>:</h4>
<p>You want a dynamic check, which isn't possible</p>



<a name="147827962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147827962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147827962">(Nov 16 2018 at 16:29)</a>:</h4>
<p>At least I don't see how to do that</p>



<a name="147828027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147828027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147828027">(Nov 16 2018 at 16:30)</a>:</h4>
<p>Or we could, but the code for stability is fragile enough</p>



<a name="147828048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147828048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147828048">(Nov 16 2018 at 16:30)</a>:</h4>
<p>I can look into it again if you want</p>



<a name="147828210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147828210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147828210">(Nov 16 2018 at 16:32)</a>:</h4>
<p>It's the same problem that macros have</p>



<a name="147828241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147828241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147828241">(Nov 16 2018 at 16:33)</a>:</h4>
<p>Except that you can't transmute macros</p>



<a name="147828291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147828291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147828291">(Nov 16 2018 at 16:34)</a>:</h4>
<p>We don't guarantee stability of transmuting things in horrible ways already</p>



<a name="147828301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147828301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147828301">(Nov 16 2018 at 16:34)</a>:</h4>
<p>Why should we do so here?</p>



<a name="147829920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147829920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147829920">(Nov 16 2018 at 16:59)</a>:</h4>
<blockquote>
<p>You want a dynamic check, which isn't possible</p>
</blockquote>
<p>I want a check whether the current crate would consider that fn <code>const</code></p>



<a name="147829944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147829944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147829944">(Nov 16 2018 at 16:59)</a>:</h4>
<p>or, well, I thought I would. but of course execution goes into other crates, and if libstd calls some things that only it may consider <code>const</code>... I see what you mean</p>



<a name="147830013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147830013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147830013">(Nov 16 2018 at 17:00)</a>:</h4>
<p>I still do not understand why <code>len</code> fails thought, because it should be const everywhere (current crate has the feature enabled)</p>



<a name="147871218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147871218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147871218">(Nov 17 2018 at 09:26)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@Oli</span> do you have an explanation for why these test cases change in <a href="https://github.com/rust-lang/rust/issues/56007" target="_blank" title="https://github.com/rust-lang/rust/issues/56007">#56007</a>? We shouldn't even start executing that code, right?</p>



<a name="147871265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147871265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147871265">(Nov 17 2018 at 09:28)</a>:</h4>
<p>Currently we have things like <a href="https://play.rust-lang.org/?version=beta&amp;mode=debug&amp;edition=2015&amp;gist=ae04a67a3aee6e747b924223b3b37867" target="_blank" title="https://play.rust-lang.org/?version=beta&amp;mode=debug&amp;edition=2015&amp;gist=ae04a67a3aee6e747b924223b3b37867">https://play.rust-lang.org/?version=beta&amp;mode=debug&amp;edition=2015&amp;gist=ae04a67a3aee6e747b924223b3b37867</a> which are really scary IMO</p>



<a name="147875152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147875152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147875152">(Nov 17 2018 at 11:50)</a>:</h4>
<p>The problem is that we have no way of knowing whether const qualif succeeded. We should make that query return a Result</p>



<a name="147875154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147875154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147875154">(Nov 17 2018 at 11:50)</a>:</h4>
<p>And then make const eval abort with <code>AlreadyReported</code></p>



<a name="147875352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147875352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147875352">(Nov 17 2018 at 11:59)</a>:</h4>
<p>wait, you are saying the error comes from inside the <code>is_const_fn_raw</code>?</p>



<a name="147875360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147875360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147875360">(Nov 17 2018 at 11:59)</a>:</h4>
<p>I thought we are doing const qualification first, and then later we start executing this code. We shouldn't even do the latter if the former failed.</p>



<a name="147875628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147875628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147875628">(Nov 17 2018 at 12:09)</a>:</h4>
<p>we don't want to abort the entire compilation because of one failed item</p>



<a name="147875629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147875629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147875629">(Nov 17 2018 at 12:09)</a>:</h4>
<p>we just need to teach const eval to also run the const qualif query</p>



<a name="147875725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147875725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147875725">(Nov 17 2018 at 12:12)</a>:</h4>
<p>okay. no idea how that'd work, I will leave the gluing to you :D</p>



<a name="147876030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147876030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147876030">(Nov 17 2018 at 12:25)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> would it make sense to bubble up errors in e.g. <code>mir_validated</code> (by making it return a <code>Result&lt;&amp;Steal&lt;Mir&gt;, ErrorReported&gt;</code>)? <a href="https://github.com/rust-lang/rust/blob/87a3c1ee7016bbfb782f2fd8adc75b46687ef929/src/librustc_mir/transform/mod.rs#L224" target="_blank" title="https://github.com/rust-lang/rust/blob/87a3c1ee7016bbfb782f2fd8adc75b46687ef929/src/librustc_mir/transform/mod.rs#L224">https://github.com/rust-lang/rust/blob/87a3c1ee7016bbfb782f2fd8adc75b46687ef929/src/librustc_mir/transform/mod.rs#L224</a> to prevent erroneous <code>Mir</code> from being processed downstream?</p>



<a name="147878105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147878105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147878105">(Nov 17 2018 at 13:39)</a>:</h4>
<p>What the query returns when MIR for given DefId does not exist?</p>



<a name="147878106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147878106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147878106">(Nov 17 2018 at 13:39)</a>:</h4>
<p>whatever it returns there is already a perfectly fine way to prevent downstream from processing data further</p>



<a name="147878694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147878694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147878694">(Nov 17 2018 at 14:00)</a>:</h4>
<p>I don't think <code>bug!</code> makes much sense: <a href="https://github.com/rust-lang/rust/blob/9649c1f70fddd01843024932df97fb5a2b10bfe8/src/librustc_mir/build/mod.rs#L82" target="_blank" title="https://github.com/rust-lang/rust/blob/9649c1f70fddd01843024932df97fb5a2b10bfe8/src/librustc_mir/build/mod.rs#L82">https://github.com/rust-lang/rust/blob/9649c1f70fddd01843024932df97fb5a2b10bfe8/src/librustc_mir/build/mod.rs#L82</a></p>



<a name="147878751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147878751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147878751">(Nov 17 2018 at 14:02)</a>:</h4>
<p>well yeah, so queries don’t have a built-in method for reporting impossiblity to resolve the query, then?</p>



<a name="147878752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147878752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147878752">(Nov 17 2018 at 14:02)</a>:</h4>
<p>nope</p>



<a name="147878754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147878754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147878754">(Nov 17 2018 at 14:02)</a>:</h4>
<p>which means that our end goal will end up making us making <em>all</em> queries return some sort of a Result anyway.</p>



<a name="147878755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147878755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147878755">(Nov 17 2018 at 14:02)</a>:</h4>
<p><span class="emoji emoji-1f642" title="slight smile">:slight_smile:</span></p>



<a name="147878763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147878763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147878763">(Nov 17 2018 at 14:03)</a>:</h4>
<p><span class="user-mention" data-user-id="124287">@mw</span> would it make sense in general to make queries support failing?</p>



<a name="147878864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147878864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147878864">(Nov 17 2018 at 14:06)</a>:</h4>
<p>Not having queries require returning a Result is strictly more general… although with <code>Result&lt;T, !&gt;</code> that argument is somewhat moot as well.</p>



<a name="147880063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880063">(Nov 17 2018 at 14:47)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@Oli</span> I don't know how I feel about that. how erroneous are we talking?</p>



<a name="147880066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880066">(Nov 17 2018 at 14:47)</a>:</h4>
<p>like failed const qualification</p>



<a name="147880069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880069">(Nov 17 2018 at 14:47)</a>:</h4>
<p>but I can imagine other things</p>



<a name="147880108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880108">(Nov 17 2018 at 14:48)</a>:</h4>
<p>what are you thinking of preventing?</p>



<a name="147880112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880112">(Nov 17 2018 at 14:48)</a>:</h4>
<p>concretely: const eval trying to evaluate non-const MIR</p>



<a name="147880113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880113">(Nov 17 2018 at 14:48)</a>:</h4>
<p>I'd rather have a flag on the <code>Mir</code> than just throw it away entirely</p>



<a name="147880117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880117">(Nov 17 2018 at 14:48)</a>:</h4>
<p><code>Result&lt;Mir, ErrorMir&gt;</code> where the latter is a struct containing an error and the erroneous MIR?</p>



<a name="147880124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880124">(Nov 17 2018 at 14:49)</a>:</h4>
<p>I don't like that tbh</p>



<a name="147880128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880128">(Nov 17 2018 at 14:49)</a>:</h4>
<p>I guess you don't want to report duplicate errors, even if miri might not ICE</p>



<a name="147880185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880185">(Nov 17 2018 at 14:50)</a>:</h4>
<p>yea, there's places we'd rather ICE about than report an error, because they make no sense</p>



<a name="147880200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880200">(Nov 17 2018 at 14:51)</a>:</h4>
<p>I'll not do this for now and just make <code>mir_const_qualif</code> also return a flag saying that stuff broke</p>



<a name="147880206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880206">(Nov 17 2018 at 14:51)</a>:</h4>
<p>what we're missing, really, is a way to avoid error cascades</p>



<a name="147880248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880248">(Nov 17 2018 at 14:52)</a>:</h4>
<p>there's no reason we couldn't const-eval MIR that didn't pass the static checks</p>



<a name="147880256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880256">(Nov 17 2018 at 14:52)</a>:</h4>
<p>"keep going at any cost (as long as <em>someone</em> reports an error)" is my preferred philosophy</p>



<a name="147880263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880263">(Nov 17 2018 at 14:52)</a>:</h4>
<p>this could mean replacing <code>span_bug!</code>s in miri with <code>delay_span_bug</code></p>



<a name="147880334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880334">(Nov 17 2018 at 14:54)</a>:</h4>
<p>we are actually evaluating non-const-fns if const qualification fails</p>



<a name="147880335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880335">(Nov 17 2018 at 14:54)</a>:</h4>
<p>are you sure we want to go there?</p>



<a name="147880336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880336">(Nov 17 2018 at 14:54)</a>:</h4>
<p>yupp!</p>



<a name="147880337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880337">(Nov 17 2018 at 14:54)</a>:</h4>
<p>as long as someone reported an error, why not?</p>



<a name="147880345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880345">(Nov 17 2018 at 14:55)</a>:</h4>
<p>well... we can't prevent the error cascade in that case</p>



<a name="147880419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880419">(Nov 17 2018 at 14:57)</a>:</h4>
<p>I don't think we want to -- miri should be allowed to make some basic assumptions about the MIR, and <code>bug!</code> otherwise</p>



<a name="147880457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880457">(Nov 17 2018 at 14:58)</a>:</h4>
<p>we have <code>delay_span_bug</code> for a reason</p>



<a name="147880462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880462">(Nov 17 2018 at 14:58)</a>:</h4>
<p>(though it cannot <code>bug!</code> for calling non-const-fns because of transmute, but there might be other cases)</p>



<a name="147880464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880464">(Nov 17 2018 at 14:58)</a>:</h4>
<p>that doesn't help, it doesn't abort computation</p>



<a name="147880466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880466">(Nov 17 2018 at 14:58)</a>:</h4>
<p>miri then still has to do <em>something</em></p>



<a name="147880480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880480">(Nov 17 2018 at 14:59)</a>:</h4>
<p>I also dont see the point, TBH. we'd certainly want to suppress any errors that show up in such a computation, so why even perform it? just a waste of time.</p>



<a name="147880491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880491">(Nov 17 2018 at 15:00)</a>:</h4>
<p>ignore the <code>delay_span_bug</code> thing for now... I'm talking about running into code like dereferencing raw pointers, which now can suddenly happen and spit out a bunch of diagnostics that will likely not be helpful to the user</p>



<a name="147880492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880492">(Nov 17 2018 at 15:00)</a>:</h4>
<p>"because it could succeed" was part of my reasoning</p>



<a name="147880548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880548">(Nov 17 2018 at 15:00)</a>:</h4>
<p>but, sure, as long as it doesn't stop the compilation, or non-miri things from using the MIR, I'm probably fine with most solutions</p>



<a name="147880549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880549">(Nov 17 2018 at 15:00)</a>:</h4>
<blockquote>
<p>"because it could succeed" was part of my reasoning</p>
</blockquote>
<p>and then what?</p>



<a name="147880557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880557">(Nov 17 2018 at 15:01)</a>:</h4>
<p>we abort compilation anyway. the user won't even know it succeeded.</p>



<a name="147880560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880560">(Nov 17 2018 at 15:01)</a>:</h4>
<p>the computation could be an array length</p>



<a name="147880563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880563">(Nov 17 2018 at 15:02)</a>:</h4>
<p>which would wrong very often, leading to downstream type mismatches</p>



<a name="147880604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880604">(Nov 17 2018 at 15:02)</a>:</h4>
<p>I dont think we should do anything based on an array length that calls a non-const-fn...</p>



<a name="147880607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880607">(Nov 17 2018 at 15:02)</a>:</h4>
<p>(which are just noise in my book, we used to have them with old ctfe)</p>



<a name="147880608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880608">(Nov 17 2018 at 15:02)</a>:</h4>
<p>but I guess if nothing bails out completely when const-eval errors, it's probably fine</p>



<a name="147880609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880609">(Nov 17 2018 at 15:02)</a>:</h4>
<p>Basically <a href="https://github.com/rust-lang/rust/pull/56007" target="_blank" title="https://github.com/rust-lang/rust/pull/56007">https://github.com/rust-lang/rust/pull/56007</a> is trying to make sure we do not accidentally expose "stuff" on stable</p>



<a name="147880611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880611">(Nov 17 2018 at 15:02)</a>:</h4>
<p>yea, we'd just get an <code>TyKind::Err</code> instead of a <code>TyKind::Array</code> in that case</p>



<a name="147880612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880612">(Nov 17 2018 at 15:02)</a>:</h4>
<p>but in doing so we get annoying duplicate errors</p>



<a name="147880670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880670">(Nov 17 2018 at 15:04)</a>:</h4>
<p>I have ideas, I'll cook up a PR and we can see if everyone likes it</p>



<a name="147880683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880683">(Nov 17 2018 at 15:05)</a>:</h4>
<p>okay, I am curious what you are cooking :)</p>



<a name="147880743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/calling%20non-const-fn/near/147880743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/calling.20non-const-fn.html#147880743">(Nov 17 2018 at 15:07)</a>:</h4>
<p>yeah, ping me on it :D</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>